//
//  CommentCell.m
//  Contacts
//
//  Created by 李 雷川 on 14-7-19.
//  Copyright (c) 2014年 李 雷川. All rights reserved.
//

#import "CommentCell.h"

@implementation CommentCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self setupSubViews];
    }
    return self;
}

-(void)setupSubViews{
    float padding = 10;
    float headWidth = 48;
    float headHeight = 48;
    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(padding, padding,headWidth,headHeight)];
    [self addSubview:imageView];
    
    nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame), padding, 100, 44)];
    nameLabel.backgroundColor =[UIColor clearColor];
    [self addSubview:nameLabel];
    
    contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame),CGRectGetMaxY(nameLabel.frame) + padding, CGRectGetWidth(self.frame) - headWidth - 3 *padding, 44)];
    contentLabel.backgroundColor =[UIColor clearColor];
    contentLabel.textColor = [UIColor lightGrayColor];
    contentLabel.numberOfLines = 0;
    [self addSubview:contentLabel];
    
    timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.frame) - padding - 100, padding, 100, 44)];
    timeLabel.font = [UIFont systemFontOfSize:14];
    timeLabel.backgroundColor =[UIColor clearColor];
    timeLabel.textColor = [UIColor lightGrayColor];
    timeLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:timeLabel];
    
    
}

-(void)layoutSubviews{
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initWithComent:(Comment *)_comment{
    comment = _comment;
    imageView.image = [UIImage imageNamed:@"logo.png"];
    nameLabel.text = comment.commenUser.name;
    contentLabel.text = comment.conntent;
    timeLabel.text = @"13分钟";
}

@end
